<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>file/shell/smooth/resources/css/jquery.dataTables.css" />
<div class="page-title">
  <h2>Data Transaksi Konsinyasi</h2>
</div>

<?php
  $msg = $this->session->flashdata('messege').$this->session->flashdata('messege1').$this->session->flashdata('messege2');
  // $msg = $this->session->flashdata('messege2');
  $div_class = $this->session->flashdata('div_class');

  if($msg){
  echo '<div class="box"><div id="box-messages">
      <div class="messages">
        <div id="message-success" class="message message-'.$div_class.'">
          <div class="image">
            <img src="'. base_url() .'file/shell/smooth/resources/images/icons/'.$div_class.'.png" alt="Success" height="32" />
          </div>
          <div class="text"><h6>'. $msg .'</h6></div>
          <div class="dismiss"><a href="#message-success"></a></div>
        </div>
      </div>
    </div></div>';
  }
?>

<table id="dataList" width="100%" class="dataTable">
  <thead>
    <tr>
      <th width="50px">ID</th>
      <th width="80px">Tanggal</th>
      <th>Sales ID</th>
      <th>Sales Name</th>
      <th>Partner ID</th>
      <th>Partner Name</th>
      <th width="80px">Jatuh Tempo</th>
      <th width="50px">Status</th>
    </tr>
  </thead>

  <tbody><!-- Here goes the datatables --></tbody>

</table>

<script type="text/javascript">
$(document).ready(function(){

  $('#dataList').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "aaSorting": [[ 1, "asc" ]],
    "sAjaxSource": "<?php echo base_url('index.php/consignment/dataList');?>/",
    "aoColumnDefs": [
      { "bSearchable": false, "aTargets": [ 0, 6, 7 ] }
    ],
    "fnRowCallback": function(nRow, aaData, iDisplayIndex, iDisplayIndexFull) 
    {
      $.post(
        "<?=base_url();?>index.php/outlet/fogit/",
        {outlet_id:aaData[0]},
        function(response) {
          var link = '<?php echo base_url(); ?>index.php/consignment/detail/'
          var href = link+response;
          $('#dataList tbody tr').eq(iDisplayIndex).find('td').eq(-1).after('<td><a href="'+href+'">Detail</a></td>')

        }
      );
      return nRow;
    }
  });
  $('#dataList thead tr').find('th').eq(-1).after('<th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 150px" aria-label="Action">Action</th>');

});
</script>